package org.example.doctorapi.controller;

import org.example.doctorapi.data.SysDept;
import org.example.doctorapi.data.SysUser;
import org.example.doctorapi.server.SysUserServer;
import org.example.doctorcommon.util.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/system/user")
public class SysUserController {
    @Autowired
    private SysUserServer sysUserServer;
    @GetMapping("/listDeptForPage")
    public BaseResult listDeptForPage(@Validated SysUser sysUser){
        return BaseResult.ok(sysUserServer.getDict(sysUser));
    }
    @PostMapping("/addUser")
    public BaseResult addDept(@Validated SysUser sysUser){
        sysUserServer.insertOne(sysUser);
        return BaseResult.ok("添加成功");
    }

    @PostMapping("/updateUser")
    public BaseResult updateDept(@Validated SysUser sysUser){
        sysUserServer.updateOne(sysUser);
        return BaseResult.ok("跟新成功");
    }

    @DeleteMapping("/delete")
    public BaseResult delete(List<Integer> dis){
        sysUserServer.deleteList(dis);
        return BaseResult.ok("删除成功");
    }
    @GetMapping("/resetPwd/{userIds}")
    public BaseResult updatePassword(@PathVariable Integer userIds, String password){
        sysUserServer.updatePassword(userIds,password);
        return BaseResult.ok("修改成功");
    }
    // 给用户分配角色	/system/user/saveUserRole
    // 查询所有角色信息	/system/role/selectAllRole
    // 根据用户ID查询角色	/system/role/getRoleIdsByUserId/{userId}
}
